package com.alisls.demo.springcloud.service.user.entity;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;

import javax.persistence.*;
import java.util.List;

/**
 * 员工
 *
 * @author Ke Wang
 * @date 2020/10/30
 */
@Entity
@Table(name = "sys_employee")
@Getter
@Setter
@NoArgsConstructor
@ToString
public class EmployeeDO extends BizDO {

    /**
     * 员工编号
     */
    @Column(nullable = false, unique = true, length = 30)
    private String employeeNo;

    /**
     * 员工昵称
     */
    @Column(nullable = false, length = 128)
    private String nickname;

    /**
     * 员工名称
     */
    @Column(length = 64)
    private String firstname;

    /**
     * 员工姓氏
     */
    @Column(length = 64)
    private String lastname;

    /**
     * 员工手机号码
     */
    @Column(length = 32, unique = true)
    private String mobile;

    /**
     * 员工邮箱
     */
    @Column(length = 128, unique = true)
    private String email;

    /**
     * 员工年龄
     */
    private Integer age;

    /**
     * 一个员工有多个用户
     * 注解@JoinColumn(name = "employee_id")会在表sys_user中增加一个字段employee_id，
     * 并且会将字段employee_id设置为外键
     */
    @OneToMany
    @JoinColumn(name = "employee_id")
    //@JoinColumn(name = "employee_no", referencedColumnName = "employeeNo") // TODO 想改成employee_no做为外键保存报错
    private List<UserDO> users;

}
